package bishi.beike;

import java.util.Arrays;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/13 20:21
 */
public class one {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(FarmerNN(4,6)));
    }
    public static long[] FarmerNN(int n, long m) {
        long[] res = new long[n];
        if (n > m) {
            for (int i = 0; i < m; i++) {
                res[i] = 1;
            }
            return res;
        }
        m-=n;
        long row = m/(n-1);
        int duo = (int) (m%(n-1));
        boolean p = row%2==0;//反向，左为true
        if (p){
            res[0] = row/2+1;
            res[n-1] = row/2+1;
        } else {
            res[0] = row/2+1+1;
            res[n-1] = row/2+1;
        }
        int left = p?(n - 2 - duo) :0;//>left
        int right = p?n-1:duo+1;//<right
        for (int i=1;i<n-1;i++){
            res[i] = row+1;
            if (i>left&&i<right){
                res[i]++;
            }
        }
        return res;

        // write code here
    }
}
